約 4,536,852 件
https://w.atwiki.jp/nicoratch/pages/1087.html
概要 CMD DV-1はソフトウェア上で最高4つまでのデッキをコントロールする事が可能なDJ用コントローラーです。Deckadanceはもちろん、Ableton/LiveやNative Instruments/TRAKTORなどの主要DJソフトウェアにも対応している為、DJプレイをより快適にしてくれる商品です。 スペック表 ■DJ用コントローラー ■ソフトウェア上で最高4つまでのデッキをコントロールする事が可能。 ■Deckadance DJソフトウェア付属(ダウンロード対応) ■Ableton/Live、Native Instruments/TRAKTORなど主要DJソフトのMIDIマップをメーカーサイトからダウンロード可能 ■USBバスパワー対応 ■BEHRINGER CMDコントローラと一緒に組み合わせるように設計されたスリム卓上設計 ■寸法:15.2(W)×30.5(H)×5.7(D)cm 重量:0.9kg ※Deckadance LEをダウンロードしてお使い下さい。 価格 ¥11,800(税抜) CMD DV-1 http //www.hotlinemusic.co.jp/products/cmd-dv-1.html
https://w.atwiki.jp/sampleisbest/pages/305.html
開発環境 Microsoft Visual C++ 2013 実行環境 Microsoft Windows 8.1 (64bit) プロジェクトの種類 Win32 コンソール アプリケーション プロジェクト名 code2smf アプリケーションの種類 コンソール アプリケーション 追加のオプション 空のプロジェクト, SDLチェック code2smf.cpp // マルチバイト文字セット #include ctype.h #include stdio.h #include stdlib.h #include string.h #include Windows.h #include map using namespace std; #define AC(a) a, _countof(a) struct Data { BYTE cmd; BYTE d1; BYTE d2; }; typedef multimap DWORD, Data DataList; // 関数プロトタイプ宣言 int GetNoteLen(const char* p); int NoteName(const char* p, int tick_a, int tick_n); int GetValue(const char* p, int* value); void Output(LPCTSTR path_in); void WriteBE(int len, DWORD val); void WriteData(DWORD t, BYTE cmd, BYTE d1, BYTE d2); // 外部変数 int timebase = 480; int q = 7;// 音の長さの割合 q/8 char flat[16]; FILE* pfo; int datalen;// データ長 DataList list; //============================================================================== int main(int argc, char* argv[]) { if (argc != 2) { fprintf(stderr, "usage code2smf codefile\n"); return 1; } char path_in[_MAX_PATH]; strcpy_s(path_in, argv[1]); // ヘッダ GetPrivateProfileString("head", "b", NULL, AC(flat), path_in); // 入力ファイル FILE* pfi; if (fopen_s( pfi, path_in, "rt") != 0) { fprintf(stderr, "error %s\n", path_in); return 1; } // 読み込みループ char line[256]; BOOL track = FALSE; int row = 0; while (fgets(AC(line), pfi) != NULL) { row++; int len = strlen(line); if (0 len line[len - 1] == \n ) line[len - 1] = \0 ;// 改行文字を削除 char* p = strchr(line, ; ); if (p != NULL) *p = \0 ;// コメントアウトを削除 if (line[0] == \0 ) continue; if (track == FALSE) { if (_stricmp(line, "[track1]") == 0) track = TRUE; continue; } int bar, numer, denom;// 小節、分子、分母 char notelen[16];// 音長 char notename[16];// 音名 int field = sscanf_s(line, "%d %d/%d %s %s", bar, numer, denom, AC(notelen), AC(notename)); if (field != 5) { fprintf(stderr, "error %s\n", line); break; } // 音長 int tick_n = GetNoteLen(notelen); if (tick_n = 0) { fprintf(stderr, "error %s\n", line); break; } // 音名処理 int tick_a = (4 * timebase) * (bar - 1) + (4 * timebase) * numer / denom; if (NoteName(notename, tick_a, tick_n) != 0) { fprintf(stderr, "error %s\n", line); break; } printf("[%s] %d %d %d/%d t=%d\n", line, field, bar, numer, denom, tick_n); } fclose(pfi); Output(path_in); return 0; } // 音長の取得 int GetNoteLen(const char* p) { int tick = 0; for (int c = 0; p[c]; ) { // 音長 int value; c += GetValue(p + c, value); if (value == 0) return 0; // 付点 int dot = 0; for ( ; p[c] == . ; c++) dot++; int t = timebase * 4 / value; t += t * ((1 dot) - 1) / (1 dot); tick += t; // タイ if (p[c] == ) c++; } return tick; } // 音名処理 int NoteName(const char* p, int tick_a, int tick_n) { const int scale[] = { 9, 11, 0, 2, 4, 5, 7 };// 音階 if (p[0] == r ) return 0;// 休符 int ch = 0; for (int c = 0; p[c]; ch++) { // 音名 char name = p[c++]; int n = name - a ; if (n 0 || 7 n) { return -1; } // オクターブ int octave; c += GetValue(p + c, octave); if (octave 1 || 7 octave) { return -1; } // 臨時記号 accidental int acci = 0; switch (p[c]) { case + case # acci++; c++; break; case - acci--; c++; break; } if (acci == 0) { if (strchr(flat, name) != NULL) { acci = -1; } } int notenum = (octave + 1) * 12 + scale[n] + acci; Data data; data.cmd = 0x90 | ch;// note on data.d1 = notenum; data.d2 = 0x70; list.insert(make_pair(tick_a, data)); data.cmd = 0x80 | ch;// note off data.d1 = notenum; data.d2 = 0x00; list.insert(make_pair(tick_a + tick_n * q / 8, data)); } return 0; } // 値の取得 int GetValue(const char* p, int* value) { int c = 0; *value = 0; for ( ; isdigit(p[c]); c++) { *value = *value * 10 + (p[c] - 0 ); } return c; } //------------------------------------------------------------------------------ // SMFファイルへの出力 void Output(LPCTSTR path_in) { // 出力ファイル char drv[_MAX_DRIVE]; char dir[_MAX_DIR]; char fnm[_MAX_FNAME]; char ext[_MAX_EXT]; char path_out[_MAX_PATH]; _splitpath_s(path_in, drv, dir, fnm, ext); _makepath_s(path_out, drv, dir, fnm, "mid"); if (fopen_s( pfo, path_out, "wb") != 0) { fprintf(stderr, "error %s\n", path_out); return; } // ヘッダチャンク fwrite("MThd", 1, 4, pfo); WriteBE(4, 6);// データ長 WriteBE(2, 0);// フォーマットタイプ WriteBE(2, 1);// トラック数 WriteBE(2, timebase);// タイムベース // トラックチャンク fwrite("MTrk", 1, 4, pfo); WriteBE(4, 0);// データ長(仮) datalen = 0; DWORD tick = 0; for (DataList iterator it = list.begin(); it != list.end(); it++) { DWORD delta = it- first - tick; Data data = it- second; WriteData(delta, data.cmd, data.d1, data.d2); tick = it- first; //printf("%u %x %u %x\n", it- first, data.cmd, data.d1, data.d2); } // トラック終了 WriteData(0, 0xff, 0x2f, 0x00); fseek(pfo, -4 - datalen, SEEK_CUR); WriteBE(4, datalen);// データ長 fclose(pfo); } void WriteBE(int len, DWORD val) { BYTE* p = (BYTE*) val + len; for (int n = 0; n len; n++) { fwrite(--p, 1, 1, pfo); } datalen += len; } void WriteData(DWORD t, BYTE cmd, BYTE d1, BYTE d2) { // 可変長tick DWORD v = ((t 0xfe00000) 3) | ((t 0x1fc000) 2) | ((t 0x3f80) 1) | (t 0x7f) | 0x80808000; BYTE* p = (BYTE*) v + 4; for (int n = 0; n 4; n++) { if (*--p != 0x80) { fwrite(p, 1, 1, pfo); datalen++; } } fwrite( cmd, 1, 1, pfo); fwrite( d1, 1, 1, pfo); fwrite( d2, 1, 1, pfo); datalen += 3; } ivi.txt [head] [track1] ; 小節 分子/分母 音長 音名 1 0/8 2 c4e4g4c5 1 4/8 2 g3d4g4b4 2 0/8 2 c4e4g4c5 2 4/8 2 r
https://w.atwiki.jp/progtips/pages/13.html
ソース setlocal set argc=0 for %%a in (%*) do set /a argc+=1 解説 if "%1"=="" などとしてもよいが、%1の内容にクォートが含まれる場合にはエラーになってしまう。たとえば、下記のように"Program Files"を含みたいような場合。 %1="C \Program Files\" if ""C \Program Files\""=="" echo 1 Files\""=="" の使い方が誤っています。 引数の全指定 "%*" はSHIFTの影響を受けないので、以下のようなソースの場合には問題を生ずる。 echo [%*] %1 %2 %3 %4 %5 shift echo [%*] %1 %2 %3 %4 %5 shift echo [%*] %1 %2 %3 %4 %5 引数として(1 2 3 4 5 6 7 8)を与えた場合: [1 2 3 4 5 6 7 8] 1 2 3 4 5 [1 2 3 4 5 6 7 8] 2 3 4 5 6 [1 2 3 4 5 6 7 8] 3 4 5 6 7 上記の方法では%1と%2を固定しつつ、それ以降を%*として使い、%10以上も安全にアクセスできるようにすることができない(SHIFTをしても%*がシフトされないため)。 実例 alias.cmd @echo off setlocal set argc=0 for %%a in (%*) do set /a argc+=1 set name=%1 set prog=%2 if %argc% lss 2 ( echo usage alias alias-name binary-path echo example alias ls c \bin\ls.exe ) else ( echo @echo off d \bin\%name%.cmd echo %prog% %3 %4 %4 %5 %6 %7 %8 %9 %%* d \bin\%name%.cmd )
https://w.atwiki.jp/nicoratch/pages/1086.html
概要 CMD DC-1は16個の大型バックライトパッドと8つの大型ロータリーが搭載されたMIDIコントローラーです。 パッドにはサンプルをアサインする事が出来、サンプラーとして使用する事が可能。 また、Ableton LiveやTRAKTORにも対応している為楽曲制作の用途でも力を発揮する事が出来ます。 スペック表 ■DJ用コントローラー ■16個の大型バックライトパッド、8つの大型ロータリー搭載のMIDIコントローラー。 ■PC内のライブラリーから楽曲のセレクトとロードができるナビゲーションセクション ■Deckadance DJソフトウェア付属(ダウンロード対応) ■Ableton/Live、Native Instruments/Traktorなど主要DJソフトのMIDIマップをメーカーサイトからダウンロード可能 ■USBバスパワー対応 ■BEHRINGER CMDコントローラと一緒に組み合わせるように設計されたスリム卓上設計 ■寸法:15.2(W)×30.5(H)×5.7(D)cm 重量:0.9kg ※Deckadance LEをダウンロードしてお使い下さい。 価格 ¥10,584(税込) CMD DC-1 http //www.hotlinemusic.co.jp/products/cmd-dc-1.html
https://w.atwiki.jp/standalonecomplex/pages/21.html
S.A.Cの条件 S.A.Cの定義はS.A.Cとはで一度述べましたが、S.A.Cの実態を掴み、また本物のS.A.Cと、S.A.Cに見せかけた紛い物とを区別するためには、幾つかのチェックポイントが必要と考えます。以下、その条件を順に検討していきたいと思います。 1)同時多発的である。 2)各人が自主性を持って、したいことを行う。 3)カリスマ的な先導者が存在する、あるいは、ノウハウ的なものが存在している。(←N型のみ?) 4)ある程度の方向性・ルールを持っている 5)分子間にオープンな情報共有システムが存在し、実際に活発な情報交流が行われている。(SNS、掲示板、MLなど)(i-share) 6)硬直的でなく、分子同士が有機的に連なる。即ち各人が同じ方向を向いているとは限らないし、互いにそれを認めている。無理に同じ方向に揃えようとしない。 7)Stand play(自己完結できる)な活動が存在する。 8)馴れ合いが少ない。 9)ある程度の匿名性。 1)同時多発的である。 S.A.Cにおいては、各人がしたいことをするのが原則になります。そのため、「やりたい人が、やりたい事を、やりたいときにやる」ので、複数の人間が同じタイミングで同じ事を行う、といった現象が起こります。これを、互いにタイミングを調整するようなことを恒常的にやっているような場合には、S.A.Cとは言えなくなります。 2)各人が自主性を持って、したいことを行う。 強要されて、また必要以上の使命感から行う行動はS.A.Cを構築しません。 3)カリスマ的な先導者が存在する、あるいは、ノウハウ的なものが存在している。(←N型のみ?) 4)ある程度の方向性・ルールを持っている 硬直・単一的な「目標」「目的」を設定することではありませんのでご注意を。また、仮想中心を持っています。 5)分子間にオープンな情報共有システムが存在し、実際に活発な情報交流が行われている。(SNS、掲示板、MLなど)(i-share) 6)硬直的でなく、分子同士が有機的に連なる。即ち各人が同じ方向を向いているとは限らないし、互いにそれを認めている。無理に同じ方向に揃えようとしない。 7)Stand play(自己完結できる)な活動が存在する。 8)馴れ合いが少ない。 攻殻機動隊に「チームプレイではなく、スタンドプレイから生じるチームワーク」という名言がありますが、理想的なS.A.Cもこれに近い状態になると思われます。 9)ある程度の匿名性。 編集
https://w.atwiki.jp/notsearch/pages/135.html
60 風吹けば名無し 2019/05/01(水) 12 11 51.82 ID FI82sX1s00501 外来種やからって人間だけの都合で殺すのはどうなんや 外来種かて生きとるやろ 68 風吹けば名無し 2019/05/01(水) 12 12 48.19 ID EyBu0TQAd0501 60 君かて部屋に虫とかでたら○すやろ? 同じ穴のムジナや 74 風吹けば名無し 2019/05/01(水) 12 13 58.82 ID FI82sX1s00501 68 ムジナってなんや 80 風吹けば名無し 2019/05/01(水) 12 14 39.66 ID kQFrGz2E00501 74 タヌキや 86 風吹けば名無し 2019/05/01(水) 12 15 03.77 ID FI82sX1s00501 80 タヌキって外来種やったんか
https://w.atwiki.jp/langc/pages/18.html
Exercise 1-1. Run the ``hello, world program on your system. Experiment with leaving out parts of the program, to see what error messages you get. #include stdio.h #define Kyou int#define No0 main(){#define Boku printf(#define No1 "Hello"#define Bangohann " World¥n"#define Ha );#define Chicken return#define Curry 0;} Kyou No0 Boku No1 Bangohann Ha Chicken Curry Exercise 1-2. Experiment to find out what happens when printf s argument string contains \c, where c is some character not listed above. #include stdio.h int main(void){ printf("hello world¥c"); return 0;} Exercise 1-3. Modify the temperature conversion program to print a heading above the table. #include stdio.h int main(void){ float fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; fahr = lower; puts("----------------"); puts("| F | C |"); puts("----------------"); while(fahr = upper){ celsius = (5.0/9.0) * (fahr - 32.0); printf("| %3.0f | %6.1f |¥n", fahr, celsius); fahr = fahr + step; } puts("----------------");} Exercise 1-4. Write a program to print the corresponding Celsius to Fahrenheit table. #include stdio.h int main(void){ float fahr, celsius; int lower, upper, step; lower = -17; upper = 148; step = 20; celsius = lower; puts("----------------"); puts("| C | F |"); puts("----------------"); while(celsius = upper){ fahr = (9.0/5.0)*celsius + 32.0; printf("| %3.0f | %6.1f |¥n", celsius, fahr); celsius += step; } puts("----------------");} Exercise 1-5. Modify the temperature conversion program to print the table in reverse order, that is, from 300 degrees to 0. #include stdio.h int main(void){ float fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; fahr = upper; puts("----------------"); puts("| F | C |"); puts("----------------"); while(fahr = lower){ celsius = (5.0/9.0) * (fahr - 32.0); printf("| %3.0f | %6.1f |¥n", fahr, celsius); fahr = fahr - step; } puts("----------------");} Exercise 1-6. Verify that the expression getchar() != EOF is 0 or 1. #include stdio.h int main(void){ int value = 0; do{ printf("getchar() != EOF %d¥n", (value = getchar()) != EOF); getchar(); }while(value != EOF); return 0;} Exercise 1-7. Write a program to print the value of EOF. #include stdio.h int main(void){ char value = getchar(); printf("EOF d %d c %c ¥n", value, value); return 0;} Exercise 1-8. Write a program to count blanks, tabs, and newlines. #include stdio.h int main(void){ int tabs = 0, spaces = 0, returns = 0; char c; while( (c = getchar()) != EOF) { if(c == ¥n ) returns++; if(c == ¥t ) tabs++; if(c == ) spaces++; } printf("TAB %d times ¥n" "SPACE %d times ¥n" "RETURN %d times ¥n", tabs, spaces, returns); return 0;} Exercise 1-9. Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank. #include stdio.h int main(void){ char c; while((c = getchar()) != EOF) { if(c == ){ putchar( ); while((c = getchar()) == ){} if(c != EOF) putchar(c); } putchar(c); } return 0;} Exercise 1-10. Write a program to copy its input to its output, replacing each tab by \t, each backspace by \b,and each backslash by \\. This makes tabs and backspaces visible in an unambiguous way. #include stdio.h int main(void){ char c; while((c = getchar()) != EOF) { if(c == ¥b ){ printf("¥¥b"); continue; } if(c == ¥t ){ printf("¥¥t"); continue; } if(c == ¥¥ ){ printf("¥¥¥¥"); continue; } putchar(c); } return 0;} Exercise 1-11. How would you test the word count program? What kinds of input are most likely to uncover bugs if there are any? I think that the program have to be examined with the set of sentence we already counted it up. It s of course, needless to say, the set of sentence have to be contained with all the factors that the sentence would have, spaces, newlines,etc... Exercise 1-12. Write a program that prints its input one word per line. #include stdio.h int main(void){ char c; while((c = getchar()) != EOF) { if(c == ¥n || c == ¥t || c == ) { puts(""); while((c = getchar()) == ¥n || c == ¥t || c == ){} } putchar(c); } return 0;} Exercise 1-13. Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging. #include stdio.h #define WORD_LENGTH_MAX 20 int main(void){char c;int i;int finish_flag = 0;int length_counter = 0;int words[WORD_LENGTH_MAX] = {0};while((c = getchar()) != EOF){if( c == \n || c == \t || c == ){if(length_counter == 0){continue;}words[length_counter]++;length_counter = 0;continue;}length_counter++;}for(i = 0;i WORD_LENGTH_MAX; i++){printf("%3d", i);}while(!finish_flag){finish_flag = 1;puts(""); for(i = 0;i WORD_LENGTH_MAX; i++){ if(words[i]-- 0){finish_flag = 0; printf(" *");}else{printf(" ");}}}puts("");return 0;} Exercise 1-14. Write a program to print a histogram of the frequencies of different characters in its input. #include stdio.h int main(){char c;int i;int char_count[128] = {0};while(( c = getchar()) != EOF){char_count[(int)c]++;}for(i = 0;i 128; i++){printf("%c ", i);while(char_count[i]-- 0)printf(" * ");puts("");}} Exercise 1-15. Rewrite the temperature conversion program of Section 1.2 to use a function for conversion. #include stdio.h #define LOWER 0#define UPPER 300#define STEP 20int conversion(int fahr){return 5 * (fahr - 32) / 9;} int main(void){int fahr;fahr = LOWER;printf(" F C \n");while(fahr = UPPER){printf(" %3d %3d \n", fahr, conversion(fahr));fahr += STEP;}} Exercise 1-16. Revise the main routine of the longest-line program so it will correctly print the length of arbitrary long input lines, and as much as possible of the text. #include stdio.h #define MAXLINE 1000 int getline(char line[],int maxline); main(){ int len,max; int target; char line[MAXLINE], longest[MAXLINE]; max = 0; printf("input the number of the words you want to fetch\n"); scanf("%d", target); getchar(); while((len = getline(line, MAXLINE)) != -1 ) if(len == target) printf("%d letters %s", len, line);}int getline(char s[], int lim){ int c,i; for(i = 0; i lim - 1 (c = getchar()) != EOF c!= \n ;++i) s[i] = c; if(c == \n ) { s[i] = c; ++i; } s[i] = \0 ; if(c != EOF) return i-1; else return -1;} Exercise 1-17. Write a program to print all input lines that are longer than 80 characters. #include stdio.h #define MAXLINE 1000#define WORDSPERLINE 500 typedef struct{ char letters[WORDSPERLINE]; int wordsCounter;}WORD;int getline(char array[]); int main(){ WORD lp80[MAXLINE]; int i = 0,j; while((lp80[i].wordsCounter = getline(lp80[i].letters)) 0){ if(lp80[i].wordsCounter = 80) i++; } for(j = 0; j i; j++){ printf("%d letters %s\n", lp80[j].wordsCounter, lp80[j].letters); }} int getline(char array[]){ char c; int i = 0,count = 0; while((c = getchar()) != EOF c != \n ){ array[i++] = c; count++; } return count;} Exercise 1-18. Write a program to remove trailing blanks and tabs from each line of input, and to delete entirely blank lines. #include stdio.h #define MAXLINE 1000#define WORDSPERLINE 500 typedef struct{ char letters[WORDSPERLINE]; int wordsCounter;}WORD;int getline(char array[]);int backSearch(WORD text[],int i);int finish_flag = 0; int main(){ WORD text[MAXLINE]; int ai; int i = 0,j; while((text[i].wordsCounter = getline(text[i].letters)) = 0){ if(finish_flag == 1) break; if(text[i].wordsCounter = 1) i++; } ai = backSearch(text, i); puts("---------------------------RESULT----------------------------"); for(j = 0; j ai; j++){ printf("%d letters %s\n", text[j].wordsCounter, text[j].letters); }} int getline(char array[]){ char c; int i = 0,count = 0; while((c = getchar()) != EOF c != \n ){ array[i++] = c; count++; } if(c == EOF) finish_flag = 1; return count;}int backSearch(WORD text[],int i){ int j,k; for(j = i-1; j = 0; j--){ for(k = text[j].wordsCounter - 1; k = 0; k--){ if(text[j].letters[k] != \n text[j].letters[k] != \t )break; if(--text[j].wordsCounter == 0)i--; } } return i;} Exercise 1-19. Write a function reverse(s) that reverses the character string s. Use it to write a program that reverses its input a line at a time. #include stdio.h #include string.h #define MAXLETTERS 500void reverse(char s[]); int main(void){ char sentence[MAXLETTERS]; char letter_checked; char reversed[MAXLETTERS]; int i = 0, num; while((letter_checked = getchar()) != EOF || (i == MAXLETTERS - 1)){ sentence[i++] = letter_checked; } sentence[i++] = \0 ; printf("%s", sentence); reverse(sentence); printf("%s", sentence);} void reverse(char s[]){ char reversed[MAXLETTERS]; int i; int last_point; for(i = 0; i MAXLETTERS; i++){ if(s[i] == \0 ){ last_point = i-2; break; } } for(i = last_point; i = 0; i--){ reversed[i] = s[last_point - i]; } reversed[last_point + 1] = \0 ; strcpy(s, reversed); return;} Exercise 1-20. Write a program detab that replaces tabs in the input with the proper number of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns. Should n be a variable or a symbolic parameter? #include stdio.h #include string.h #define WORD_MAX 1000#define TABtoSPACE 1void detab(char s[]); int main(void){ char strings[WORD_MAX]; char check_c; int i = 0; while((check_c = getchar()) != EOF) strings[i++] = check_c; strings[i] = \0 ; detab(strings); printf("%s\n", strings);} void detab(char s[]){ int i = 0,j,new = 0; char fixedOne[WORD_MAX]; while(i WORD_MAX-1 s[i] != \0 ){ if(s[i] == \t ){ for(j = 0;j TABtoSPACE; j++)fixedOne[new++] = ; i++; } fixedOne[new++] = s[i++]; } fixedOne[new] = \0 ; strcpy(s, fixedOne);} Exercise 1-21. Write a program entab that replaces strings of blanks by the minimum number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. When either a tab or a single blank would suffice to reach a tab stop, which should be given preference? #include stdio.h #include string.h #define MAX_WORD 500void entab(char s[]); int main(void){ char string[500]; int i = 0; char check_c; while((check_c = getchar()) != EOF i 500) string[i++] = check_c; string[i] = \0 ; entab(string); printf("%s\n", string);} void entab(char s[]){ int i = 0, j = 0; char fixedOne[MAX_WORD]; while(s[i] != \0 ){ if(s[i] == ){ fixedOne[j++] = s[i]; while(s[++i] == ){} }else if(s[i] == \t ){ fixedOne[j++] = s[i]; while(s[++i] == \t ){} }else fixedOne[j++] = s[i++]; } fixedOne[j] = \0 ; strcpy(s, fixedOne);} Exercise 1-22. Write a program to ``fold long input lines into two or more shorter lines after the last non-blank character that occurs before the n-th column of input. Make sure your program does something intelligent with very long lines, and if there are no blanks or tabs before the specified column. #include stdio.h #define MAX_WORD 500#define FOLD_POINT 20#define MAX_ROW 10void fold(char s[]); int main(void){ char string[MAX_WORD]; int i = 0; int check_c; while((check_c = getchar()) != EOF) string[i++] = check_c; string[i] = \0 ; fold(string);}void fold(char s[]){ int blank_point = -1; int flag = 0; int i = 0, j = 0, row = 0, p = 0; char foldedString[MAX_ROW][MAX_WORD + 1]; while(s[i] != \0 ){ //find fold_point? if(s[i] == \t || s[i] == ){ blank_point = j; foldedString[row][j++] = s[i++]; }else if(s[i] == \n ){ foldedString[row++][j] = \0 ; j = 0; flag = 0; blank_point = -1; } if(j == FOLD_POINT){ if(blank_point != -1){flag = 1;foldedString[row][blank_point] = ~ ;//foldedString[row][MAX_WORD] = 1 ; } } foldedString[row][j++] = s[i++]; } //deal with backwards while(p = row){ for(i = 0; foldedString[p][i] != ~ i MAX_WORD; i++){} foldedString[p++][++i] = \0 ; } puts("-----------------------------------------------------"); for(p = 0; p = row; p++) printf("%s\n", foldedString[p]);} Exercise 1-23. Write a program to remove all comments from a C program. Don t forget to handle quoted strings and character constants properly. C comments don t nest. #include stdio.h #include string.h #define MAX_CHAR 500 void removeComment(char s[]); int main(void){ char string[MAX_CHAR]; char check_c; int i = 0; while((check_c = getchar()) != EOF) string[i++] = check_c; string[i] = \0 ; removeComment(string); printf("%s\n", string);}void removeComment(char s[]){ int i = 0,j = 0; char removed[MAX_CHAR]; while(s[i] != \0 ){ if(s[i] == / s[i+1] == / ){i += 2;while(s[i] != \n ){i++;}removed[j++] = \n ; }else if(s[i] == / s[i+1] == * ){i += 2;while(s[i] != * || s[i+1] != / ){i++;}i += 2; }elseremoved[j++] = s[i++]; } removed[j] = \0 ; strcpy(s, removed);} Exercise 1-24. Write a program to check a C program for rudimentary syntax errors like unmatched parentheses,brackets and braces. Don t forget about quotes, both single and double, escape sequences, and comments. (This program is hard if you do it in full generality.) #include stdio.h #include string.h #define MAX_CHAR 500void removeComment(char s[]);int parenthis_check(char s[]);int main(void){ int i = 0; char check_c, string[MAX_CHAR]; while((check_c = getchar()) != EOF) string[i++] = check_c; string[i] = \0 ; removeComment(string); if(parenthis_check(string)) printf("syntax error\n"); else printf("Correct\n"); printf("%s\n", string);}void removeComment(char s[]){ int i = 0,j = 0; char removed[MAX_CHAR]; while(s[i] != \0 ){ if(s[i] == / s[i+1] == / ){i += 2;while(s[i] != \n ){i++;}removed[j++] = \n ; }else if(s[i] == / s[i+1] == * ){i += 2;while(s[i] != * || s[i+1] != / ){i++;}i += 2; }elseremoved[j++] = s[i++]; } removed[j] = \0 ; strcpy(s, removed);}int parenthis_check(char s[]){ int i = 0, q_p = 50,init; char queue[100]; int error_flag = 0; for(init = 0;init 100; init++) queue[init] = 0 ; while(s[i] != \0 ){ if(s[i] == ( ) queue[q_p++] = s[i++]; else if(s[i] == [ ) queue[q_p++] = s[i++]; else if(s[i] == { ) queue[q_p++] = s[i++]; else if(s[i] == ) queue[q_p++] = s[i++]; else if(s[i] == ) ){ i++; if( ( != queue[--q_p]){error_flag = 1;break; } } else if(s[i] == ] ){ i++; if( [ != queue[--q_p]){error_flag = 1;break; } } else if(s[i] == } ){ i++; if( { != queue[--q_p]){error_flag = 1;break; } } else if(s[i] == ){ i++; if( != queue[--q_p]){error_flag = 1;break; } }else i++; } if(error_flag) return 1; return 0;} 名前 コメント
https://w.atwiki.jp/atgcc/pages/11.html
AboutG.C.C. 組織理念 『無駄のない仕事』 『金額に見合ったサービス』 『有能であれ』 この世界において考えうるほぼ全ての業種を扱っており そのなかでも、医療技術、製造技術、輸送技術などの飛躍した技術をもっているのが "General Contract Company"という企業。 この企業は世界中の発展途上国から先進国、すべての国に存在している。 "契約国"と言うシステム存在しており、 G.C.C.と国が契約することにより高待遇のサポートを受けるというシステム。 しかし契約するには高額な金額と政治干渉などのデメリットがあるが、多数の先進国が契約するのはこの"サポート"によるものである。 世間的には悪いところがない企業として知られておりG.C.C.は発展途上国などにも支援をし、 信頼できる安全な製品を作る優良企業であるという認識だ。 世間的には悪いところがない企業として知られているが。先進国ほどの軍事力の所持や飛躍しすぎている技術、 巨大すぎる企業規模などから、疑問視や良く思わない人たちもいる、 だがG.C.C.のおかげで豊かになっていたり、 G.C.C.が無くなれば大混乱が起きるのも事実であるため、誰も手出しできない。 AboutExecutive.Systems 医療 製造 輸送 商売 教育福祉 金融 第一次産業 宇宙開発 情報 全部門を合わせ数万人以上の社員が所属しているG.C.C.では大量の人材を一人で管理するのが大変なため、幹部システムを採用しております。 このシステムはG.C.C.が全業種をカバーするため、幹部が各部門の社長のような役割をすることです。 幹部は大きく分けて"主幹部"と"支店幹部"で分けられており、主に幹部と指されるのは"主幹部"の人たちです。 主幹部は社長を含めると10人程度であり、支店幹部は全世界を含めると百人存在しています。 主幹部の就任条件は三つ 「社長から信頼を得る」 「クビにできないほど有能である」 「G.C.C.に忠誠を誓う」 このうち二つを満たせば就任できます。 主幹部の主な役割は担当部門においての管理から計画のすべてを任されます。契約者や優待客がいらっしゃったときは 直接顔をお出しするといった、社長のような仕事をします。
https://w.atwiki.jp/lineeditor/pages/35.html
#include stdio.h #include stdlib.h #include string.h #define LINE_SIZE 256 #define CMD_SIZE 100 void temporary_save(void); void execmd(char *txtname, char *temp_cmd); void display_all(void); void make_undofile(char *txtname, char *temp_cmd); void save_end(void); void not_save(char *txtname); void un_do(char *txtname); void word_search1(char *txtname); void word_search2(char *txtname); void help(void); FILE *txtfile, *temp, *undo; int coe = 1; //終了条件(Condition Of End) char temp_text[L_tmpnam],undo_text[L_tmpnam];//一時的ファイルのファイル名(編集前とundo用のデータ保存用) int main(int argc, char *argv[]){ int start = 0; char cmd[CMD_SIZE]; //コマンド tmpnam(temp_text); //一時的ファイルのファイル名の決定 tmpnam(undo_text);//undo用ファイル名の決定 //ファイルの引数を調べる。 if(argc != 2){ printf("引数にはファイルのパスを指定してください\n"); exit(1); } //終了するまで無限ループ while(coe){ //ファイルが開けるかどうかを調べる。 if((txtfile = fopen(argv[1], "r")) == NULL){ printf("ファイルを開くことが出来ません"); exit(1); } //*を表示する if(start) printf("*"); else{ //変更せずに終了するときに使用する変更前のファイルの保存 temp = fopen(temp_text, "w"); temporary_save(); temp = freopen(temp_text,"r",temp); //w→rに切り替える txtfile = fopen(argv[1], "r"); //もう一回txtfileと読み込んだファイルを結びつける。 printf("ファイルを終わりまで読み込みました\n*"); start++; } //コマンドを入力 fgets(cmd, CMD_SIZE, stdin); //コマンドの実行 execmd(argv[1], cmd); //ファイルを閉じる fclose(txtfile); } fclose(temp); remove(temp_text);//一時的ファイルを削除する remove(undo_text);//undo用ファイルを削除する return 0; } //一時的ファイルの保存 void temporary_save(void){ int c; /* 文字を読み込む */ /* ファイルから EOFが現れるまで1字読み込む */ while ((c = getc(txtfile)) != EOF) { fputc(c,temp); } /* この時点でtxtfileに結びつけられたファイルは最後まで読み込まれてしまったので閉じる */ fclose(txtfile); } //機能はここに追加 void execmd(char *txtname, char *temp_cmd){ if(strcmp(temp_cmd, "l\n") == 0 || strcmp(temp_cmd, "L\n") == 0) {display_all(); return;} //すべて表示 if(atoi(temp_cmd) != 0) {make_undofile(txtname, temp_cmd); return;} //一行編集に入る前にundo用ファイルに記録 if(strcmp(temp_cmd, "e\n") == 0 || strcmp(temp_cmd, "E\n") == 0) {save_end(); return;} //保存して終了 if(strcmp(temp_cmd, "n\n") == 0 || strcmp(temp_cmd, "N\n") == 0) {not_save(txtname); return;} //保存しないで終了 if(strcmp(temp_cmd, "u\n") == 0 || strcmp(temp_cmd, "U\n") == 0) {un_do(txtname); return;} //前回の編集前の状態に戻す(undo) if(strcmp(temp_cmd, "s1\n") == 0 || strcmp(temp_cmd, "S1\n") == 0) {word_search1(txtname); return;} //単語検索(少しでも含まれてればヒット) if(strcmp(temp_cmd, "s2\n") == 0 || strcmp(temp_cmd, "S2\n") == 0) {word_search2(txtname); return;} //単語検索(トークンごとにヒット) if(strcmp(temp_cmd, "r1\n") == 0 || strcmp(temp_cmd, "R1\n") == 0) {make_undofile(txtname, temp_cmd); return;}//置換1に入る前にundo用ファイルに記録 if(strcmp(temp_cmd, "r2\n") == 0 || strcmp(temp_cmd, "R2\n") == 0) {make_undofile(txtname, temp_cmd); return;}//置換2に入る前にundo用ファイルに記録 if(strcmp(temp_cmd, "d\n") == 0 || strcmp(temp_cmd, "D\n") == 0) {make_undofile(txtname, temp_cmd); return;} //行削除に入る前にundo用ファイルに記録 if(strcmp(temp_cmd, "i\n") == 0 || strcmp(temp_cmd, "I\n") == 0) {make_undofile(txtname, temp_cmd); return;} //行挿入に入る前にundo用ファイルに記録 if(strcmp(temp_cmd, "h\n") == 0 || strcmp(temp_cmd, "H\n") == 0) {help(); return;} //ヘルプ printf("このコマンドは無効です。\n"); return; }
https://w.atwiki.jp/homework/pages/7.html
Cの宿題 よくある問題 階乗を求める 階乗を求める(再帰) 素数判定 FizzBuzz問題 ソート バブルソート (基本交換法、隣接交換法) 挿入ソート(インサーションソート、基本挿入法) 選択ソート(セレクションソート) マージソート 文字列操作 Q.文字列を読み込み、条件を満たす同じ個数の文字列を出力する Q.指定したファイルの内容に行番号をつけて表示する 未分類 Q.曲線(リサージュ)を描く Q.入力した文章の単語数と各単語の文字数を表示 Q.配列を使ってリングバッファを実装 Q.平均値と標準偏差を求めよ Q.四則演算機の作成 Q.マスターマインド(ヒット・アンド・ブロー 数当てゲーム) Q.商品ごとの売り上げ個数と月ごとの売り上げ個数を集計する Q.学生番号と氏名をメンバとする構造体を定義し、読み込む Q.身長、体重、肥満度のメンバを加えた構造体を新たに定義し、肥満度を計算する カレンダー ハッシュ スタック 最小公倍数 二進数で出力 ASCII文字表 Simpson法を使った積分 指数関数exp(x)